package com.ww.event.observer;
/**
 *
 **/

import com.ww.event.EventListener;

import java.util.EventObject;
import java.util.Observable;
import java.util.Observer;

/**
 * @Author weiwei
 * @Date 2021-08-31 11:45
 * @description eventListener转化为observer,使用适配器模式
 **/
public class EventListenerObserverAdapter implements Observer {
    
    
    private EventListener eventListener;
    
    public EventListenerObserverAdapter(EventListener listener){
        this.eventListener = listener;
    }


    @Override
    public void update(Observable o, Object arg) {
        if(arg instanceof EventObject){
            eventListener.onEvent((EventObject)arg);
        }
        
    }
}
